package bankingSystemServer;

import java.net.InetAddress;

/**
 * holds a client ip address and port
 */
public class ClientAddress {
	public InetAddress address;
	public int port;

	/**
	 * creates a new ClientAddress
	 * 
	 * @param addr
	 *            the client address
	 * @param port
	 *            the client port
	 */
	public ClientAddress(InetAddress addr, int port) {
		address = addr;
		this.port = port;
	}

	/**
	 * checks if this ClientAddress is the same as another
	 * 
	 * @param otherInfo
	 * @return true if equal
	 */
	public boolean equals(ClientAddress otherInfo) {
		if (otherInfo.port != this.port)
			return false;
		if (!otherInfo.address.equals(otherInfo.address))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return address.toString() + ':' + port;
	}
}
